package top.hundreds.oasys.bean.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

@RequiredArgsConstructor
@Getter
public enum EventStatus {
    CHECKING(0, "审核中"),
    CHECK_SUCCESS(1, "审核通过"),
    CHECK_FAIL(2, "审核驳回");

    @JsonValue
    @EnumValue
    private final Integer value;

    private final String label;

    public static EventStatus formValue(Object o) {
        if (o != null) {
            EventStatus[] eventStatuses = values();
            for (EventStatus eventStatus : eventStatuses) {
                if (eventStatus.getValue().equals(o)) {
                    return eventStatus;
                }
            }
        }
        return null;
    }

    public static EventStatus formLabel(Object o) {
        if (o != null) {
            EventStatus[] eventStatuses = values();
            for (EventStatus eventStatus : eventStatuses) {
                if(eventStatus.getLabel().equals(o)){
                    return eventStatus;
                }
            }
        }
        return null;
    }
}
